gdk: Add gdk_rectangle_equal()
authorBenjamin Otte <otte@redhat.com>
Sun, 13 Sep 2015 14:00:22 +0000 (16:00 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 4 Oct 2015 02:26:27 +0000 (22:26 -0400)
There's enough users inside GTK to warrant this convenience function.

docs/reference/gdk/gdk3-sections.txt
gdk/gdkrectangle.c
gdk/gdkrectangle.h
gtk/gtkframe.c
gtk/gtkrange.c

index 1aaefb5e6bab15d56dcdf352989c2b14249a611b..8309d1d9777ac25fed41ac8d35b962a9e7d4bf2a 100644 (file)
@@ -631,6 +631,7 @@ GdkPoint
 GdkRectangle
 gdk_rectangle_intersect
 gdk_rectangle_union
+gdk_rectangle_equal
 
 <SUBSECTION Private>
 gdk_rectangle_get_type
index 404ffcad79599b499f3b85ed6cdbb6bb1e29feb3..84abd2ffd7312c6e9020948a88579aae7a01133e 100644 (file)
@@ -133,6 +133,27 @@ gdk_rectangle_intersect (const GdkRectangle *src1,
   return return_val;
 }
 
+/**
+ * gdk_rectangle_equal:
+ * @rect1: a #GdkRectangle
+ * @rect2: a #GdkRectangle
+ *
+ * Checks if the two given rectangles are equal.
+ *
+ * Returns: %TRUE if the rectangles are equal.
+ *
+ * Since: 3.20
+ */
+gboolean
+gdk_rectangle_equal (const GdkRectangle *rect1,
+                     const GdkRectangle *rect2)
+{
+  return rect1->x == rect2->x
+      && rect1->y == rect2->y
+      && rect1->width == rect2->width
+      && rect1->height == rect2->height;
+}
+
 static GdkRectangle *
 gdk_rectangle_copy (const GdkRectangle *rectangle)
 {
index e098ea970fe1390a46a4581a794ba74b81c83399..7c0252ff0b2426a1225fa50af812929849e9dbfb 100644 (file)
@@ -45,6 +45,10 @@ void     gdk_rectangle_union     (const GdkRectangle *src1,
                                   const GdkRectangle *src2,
                                   GdkRectangle       *dest);
 
+GDK_AVAILABLE_IN_3_20
+gboolean gdk_rectangle_equal     (const GdkRectangle *rect1,
+                                  const GdkRectangle *rect2);
+
 GDK_AVAILABLE_IN_ALL
 GType gdk_rectangle_get_type (void) G_GNUC_CONST;
 
index 8a0e3e2c402b88799aaff8a319a3e7a81a78a9ab..b5fe4e574f02b9bb871e0e139df5fbd75d8be816 100644 (file)
@@ -707,16 +707,6 @@ gtk_frame_draw (GtkWidget *widget,
   return FALSE;
 }
 
-static gboolean
-rectangle_equal (const GdkRectangle *a,
-                 const GdkRectangle *b)
-{
-  return a->x == b->x
-      && a->y == b->y
-      && a->width == b->width
-      && a->height == b->height;
-}
-
 static void
 gtk_frame_size_allocate (GtkWidget     *widget,
                         GtkAllocation *allocation)
@@ -734,7 +724,7 @@ gtk_frame_size_allocate (GtkWidget     *widget,
   /* If the child allocation changed, that means that the frame is drawn
    * in a new place, so we must redraw the entire widget.
    */
-  if (gtk_widget_get_mapped (widget) && !rectangle_equal (&priv->child_allocation, &new_allocation))
+  if (gtk_widget_get_mapped (widget) && !gdk_rectangle_equal (&priv->child_allocation, &new_allocation))
     {
       gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE);
     }
index 6217ae0e7ffe356737fe2a300e3abc988eb20435..f79001771bea5e03e71323665e9122f5c45caae2 100644 (file)
@@ -3655,16 +3655,6 @@ gtk_range_compute_slider_position (GtkRange     *range,
     }
 }
 
-static gboolean
-rectangle_equal (const GdkRectangle *a,
-                 const GdkRectangle *b)
-{
-  return a->x == b->x
-      && a->y == b->y
-      && a->width == b->width
-      && a->height == b->height;
-}
-
 static void
 gtk_range_calc_slider (GtkRange *range)
 {
@@ -3675,7 +3665,7 @@ gtk_range_calc_slider (GtkRange *range)
                                      gtk_adjustment_get_value (priv->adjustment),
                                      &new_slider);
 
-  if (rectangle_equal (&priv->slider, &new_slider))
+  if (gdk_rectangle_equal (&priv->slider, &new_slider))
     return;
 
   gtk_range_queue_draw_location (range, MOUSE_SLIDER);